package com.xyoto.community.controller;

import com.xyoto.community.dto.WxLoginDTO;
import com.xyoto.community.service.WechatAuthService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author coderFu
 * @create 2021/10/1
 * 微信授权Api
 */
@RestController
@Api(value = "AuthController", tags = "微信授权模块")
@RequestMapping("wechat")
public class AuthController {

    @Resource
    private WechatAuthService wechatAuthService;


    @ApiOperation("微信授权登录接口")
    @PostMapping("/login")
    public Result wechatLogin(@Valid @RequestBody WxLoginDTO wxLoginDTO){
        return wechatAuthService.wechatLogin(wxLoginDTO);
    }

    @ApiOperation("验证Token")
    @PostMapping("/checkToken")
    public Result checkToken(){
        return wechatAuthService.checkToken();
    }

    @ApiOperation("开发者授权登录")
    @PostMapping("/devAuthLogin")
    public Result devAuthLogin(){
       return wechatAuthService.devAuthLogin();
    }

}
